from django.db import models

class Service(models.Model):
    hostname = models.CharField(maxlength=256)
    application = models.CharField(maxlength=256, default="ping")
    status = models.CharField(maxlength=256, blank=True)
    check_interval = models.IntegerField(default=5)
    checked = models.DateTimeField(null=True, blank=True)
    class Admin: 
        pass
        list_display = ('hostname', 'application', 'status', 'check_interval', 'checked')
        list_filter = ('application', 'status')
        search_fields = ('hostname', 'application', 'status')
    def __str__(self):
        return self.hostname + "/" + self.application

class Printer(models.Model):
    hostname = models.CharField(maxlength=256)
    model = models.CharField(maxlength=256)
    shared_as = models.CharField(maxlength=256)
    location = models.CharField(maxlength=256)
    owner = models.CharField(maxlength=256)
    account = models.PositiveIntegerField(null=True, blank=True)
    password = models.CharField(maxlength=256, null=True, blank=True)
    comment = models.CharField(maxlength=256, null=True, blank=True)
    
    class Admin: 
        pass
        list_display = ('hostname', 'model', 'shared_as', 'location', 'owner', 'account')
        list_filter = ('model', 'location', 'owner', 'account')
        search_fields = ('hostname', 'model', 'location', 'owner', 'account')
    def __str__(self):
        return self.hostname + " (" + self.model + ")"
        
class PrinterMaint(models.Model):
    printer_id = models.ForeignKey(Printer, edit_inline=models.STACKED, num_in_admin=1)
    date = models.DateField(core=True)
    description = models.CharField(maxlength=256, null=True, blank=True)
    page_count = models.PositiveIntegerField(null=True, blank=True)
